export {};
/* 
泛型接口
 */
interface DataType<T> {
  code: number;
  msg: string;
  result: T;
}

let obj: DataType<string[]> = {
  code: 200,
  msg: '成功',
  result: ['zs', 'li'],
};
obj.result[0].trim();

// 其余案例演示，不用练习
let data: DataType<number[]> = {
  code: 200,
  msg: '成功',
  // null [] {}
  result: [1, 2, 3, 4],
};
data.result.push(5);
// 报错
// data.result.push('5');

let data1: DataType<null> = {
  code: 400,
  msg: '失败',
  // null [] {}
  result: null,
};
// data1.result.aaa

let data2: DataType<{}> = {
  code: 200,
  msg: '成功',
  result: {},
};
